import vue from 'vue'
import vuex from 'vuex'
vue.use(vuex)

export default new vuex.Store({
    state: {
        setRightList: JSON.parse(sessionStorage.getItem('rightList') || '[]'),
        img: sessionStorage.getItem('g') || "",
        RoleID: sessionStorage.getItem('l') || "",
        UserID: sessionStorage.getItem('i') || "",
        RoleID: sessionStorage.getItem('p') || "",
        name: sessionStorage.getItem('u') || ""
    },
    mutations: {
        setRightList(state, data) {
            state.setRightList = data;
            sessionStorage.setItem('rightList', JSON.stringify(data));
        },
        img: (state, data) => {
            state.img = data;
            sessionStorage.setItem('g', data);
        },
        RoleID: (state, data) => {
            state.RoleID = data;
            sessionStorage.setItem('l', data);
        },
        UserID: (state, data) => {
            state.UserID = data;
            sessionStorage.setItem('i', data);
        },
        RoleID: (state, data) => {
            state.RoleID = data;
            sessionStorage.setItem('p', data);
        },
        name: (state, data) => {
            state.name = data;
            sessionStorage.setItem('u', data);
        }
    }
})